<template>
  <XForm ref="XForm" :formList="formList" :formData="formData">
    <template v-slot:btn>
      <el-button @click="onSubmit" type="primary">立即创建</el-button>
      <el-button @click="reset">重 置</el-button>
    </template>
  </XForm>
</template>

<script>
import { XForm } from '@/components/@fhsy/x-tool'
export default {
  components: { XForm },
  data: () => ({
    formList: [
      { label: '活动名称', prop: 'name' },
      { label: '活动区域', prop: 'region', type: 'XSelect', options: ['区域一', '区域二'] },
      { label: '活动时间', prop: 'date', type: 'XDateTime' },
      { label: '即时配送', prop: 'delivery', type: 'XSwitch', attrs: { activeText: '是', inactiveText: '否' } },
      { label: '活动性质', prop: 'type', type: 'XCheckbox', options: ['美食', '地推活动', '线下主题活动', '单纯品牌曝光'] },
      { label: '特殊资源', prop: 'resource', type: 'XRadio', options: [{ label: '码云', value: 1 }, { label: 'GitHub', value: 2 }] },
      { label: '活动形式', prop: 'desc', type: 'XTextarea', span: 24 },
      { slot: 'btn', span: 24 }
    ],
    formData: {}
  }),
  methods: {
    onSubmit () {
      this.$message(JSON.stringify(this.formData))
    },
    reset () {
      this.$refs['XForm'].resetFields() // 调用 XForm 的重置方法
    }
  }
}
</script>
